package org.yibinxueyuan.drawcard.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import org.yibinxueyuan.drawcard.entity.Cardinfo;
import org.yibinxueyuan.drawcard.pojo.Paging;
import org.yibinxueyuan.drawcard.pojo.cardinfosAndPaging;

import java.util.ArrayList;
import java.util.List;

/**@Configuration
 * 加入需要使用的对象到 ioc容器中
 */
@Configuration
public class BeanConfig {

    /**
     * 获取pojo中的cardinfosAndPaging对象
     */
    @Bean
    public cardinfosAndPaging getCardinfosAndPagingBean(){
        return new cardinfosAndPaging();
    }

    /**
     * 获取List<Integer>对象
     */
    @Bean
    public List<Integer> ArrayListBean(){
        return new ArrayList<Integer>();
    }

    /**
     * 获取List<Cardinfo>对象
     */
    @Bean
    public List<Cardinfo> ListCardinfoBean(){
        return new ArrayList<>();
    }

    /**
     * 默认的Paging参数
     * @return
     */
    @Bean(value = "pagingBean",name = "pagingBean")
    public Paging pagingBean(){
        Paging paging = new Paging();
        paging.setSize(2);  //设置每页10条数据
        paging.setPage(1);   //默认为为第一页
        paging.setCardName(null); //设置按卡片名查找,默认为空
        return paging;
    }

    @Bean
    public Cardinfo cardinfoBean(){
        Cardinfo cardinfo = new Cardinfo();
        cardinfo.setCardId(null);
        cardinfo.setCardAddress(null);
        cardinfo.setCardName(null);
        cardinfo.setCardChancef(null);
        cardinfo.setCardChancel(null);
        cardinfo.setCardChance(null);
        cardinfo.setCardLevel(null);
        cardinfo.setGameName(null);
        return cardinfo;
    }

    @Bean
    public Cardinfo cardinfoBean2(){
        Cardinfo cardinfo = new Cardinfo();
        cardinfo.setCardId(null);
        cardinfo.setCardAddress(null);
        cardinfo.setCardName(null);
        cardinfo.setCardChancef(null);
        cardinfo.setCardChancel(null);
        cardinfo.setCardChance(null);
        cardinfo.setCardLevel(null);
        cardinfo.setGameName(null);
        return cardinfo;
    }


}

